<?php
class nav extends top
{
	//重定义构造函数
    function __construct(){  
        parent::__construct();
        //定义当前导航
        $this->nav_name = 'nav';
        $this->page_title = '内容更新';
        $this->breadcrumb += array('1'=>array('name'=>'内容更新'));

    }
	function index(){	
		$data = $this->spArgs();
		//获取当前分类id
		$cat_id = isset($data['cat_id'])?$data['cat_id']:0;
		$url_id = isset($data['url_id'])?$data['url_id']:0;
		//构造左侧导航
		$url = spClass("m_url");
		$cat_result = $url->findAll(array("cat_id"=>$cat_id),'weight desc');
		$cat = spClass("m_category");
		$cat_name = $cat->find(array("id"=>$cat_id),'name');
		$this->breadcrumb += array('2'=>array('name'=>$cat_name['name']));

		foreach($cat_result as $key=>$val){
			$src_arr = explode(',',$val['content']);
			if(in_array($src_arr[0],array('article','comment','page','url','category')) && is_numeric($src_arr[1])){
				$left_nav_result[] = array(
						'id'=>$val['id'],
						'name'=>$val['title'],
						'url'=>spUrl('nav','index',array('cat_id'=>$val['cat_id'],'url_id'=>$val['id'])),
				);

				if($url_id == $val['id']){
					$src_arr = explode(',',$val['content']);
					if($src_arr[0] == 'category'){
						$this->iframe_src = "index.php?c=".$src_arr[0]."&a=index&now_cat_id=".$src_arr[1];
					}else{
						if($data['son_cat_id']){
							$this->iframe_src = "index.php?c=".$src_arr[0]."&a=index&cat_id=".$data['son_cat_id'];
						}else{
							$son_info = $cat->find(array('module'=>$src_arr[0],'father_id'=>$src_arr[1],'visible'=>1),'weight DESC');
							if(!empty($son_info)){
								$data['son_cat_id'] = $son_info['id'];
								$this->iframe_src = "index.php?c=".$src_arr[0]."&a=index&cat_id=".$son_info['id'];
							}else{
								$this->iframe_src = "index.php?c=".$src_arr[0]."&a=index&cat_id=".$src_arr[1];
							}
							
						}
						

						$this->cat_sons = $cat->findAll(array('father_id'=>$src_arr[1],'visible'=>1));
					}
					
					$this->breadcrumb += array('3'=>array('name'=>$val['title']));
				}
			}
		}
		$this->cat_id = $cat_id;
		$this->left_nav_id = $url_id;
		$this->son_cat_id = $data['son_cat_id'];
		$this->cat_result = $cat_result;
		$this->left_nav_result = $left_nav_result;



		$this->c = 'nav';
		$this->a = 'index';		
		$this->data_return = $data;		
	}
	
}